import { defineStore } from "pinia";
import {ref, reactive, computed} from "vue"
// const useTestStore = defineStore('testId',{
//         state:()=>{ return {data:10}},
//         getters: {
//                 double:(state)=>{return state.data * 10}   
//         },
//         actions:{
//               add(){
//                 this.data ++
//               }
//         }
// })

interface InterComment {
        name:string
        context:string
}

export const useCustomStroe = defineStore('CommentId',()=>{

        const comList = [
                {name:'bal', context:'vue is so easy11',isMe:false},
                {name:'lisi', context:'vue is so bad22',isMe:false},
        ]
        
        const reactList = reactive<InterComment[]>(comList);
        
        // 添加评论
        const addComment = (item:InterComment) => {
                console.log('addComment1',item)
                reactList.push(item)
        }

        // 删除评论
        const delComment =(index:number) => {
                reactList.splice(index,1)
        }

        return {reactList, addComment, delComment}
})